When the Thread Manager switches the context between one thread and another, it saves a default context, which consists of the CPU registers, the floating-point (FPU) registers (if any), and the location of the context information.
The thread context resides on a thread's stack and the Thread Manager saves the location of this context when it switches contexts between threads. The A5 register (GPR1 on the PowerPC) for each thread contains a pointer to the application's global data world. When it switches contexts, the Thread Manager initially sets A5 (GPR1) and the MMU mode to the same values as those in the main thread. In this way all threads can share in the application's global data world.
Table 1 shows the registers that the Thread Manager saves for a 680x0 application.
Table 1 Registers in the 680x0 default thread context
CPU registers | FPU registers |
---|---|
D0-D7 | FPCR, FPSR, FPIAR |
A0-A7 | FP0-FP7 |
SR (including CCR) | FPU frame |
For 680x0 applications, when you create or allocate a thread with the NewThread function, the Thread Manager provides an option that allows you to create a thread whose FPU registers are not to be saved. This allows faster context switches for threads that don't use the FPU registers.
For PowerPC applications, the Thread Manager always saves the FPU registers, regardless of any options you set because the PowerPC processor can use the FPU registers for optimizations.
Table 2 shows the registers that the Thread manager saves for a PowerPC application.
Table 2 Registers in the PowerPC default thread context
FPU registers | ||
---|---|---|
R0-R31 | FP0-FP31 | CTR, LR, PC |
FPSCR | CR, XER |